package com.sangcomz.fishbun.datasource;

import com.sangcomz.fishbun.ui.picker.model.AlbumData;
import ohos.aafwk.content.Intent;

public class PickerIntentDataSourceImpl implements PickerIntentDataSource {
    private Intent intent;

    public PickerIntentDataSourceImpl(Intent intent) {
        this.intent = intent;
    }

    @Override
    public AlbumData getAlbumData() {
        if (intent.hasParameter(ARG_ALBUM_NAME)
                && intent.hasParameter(ARG_ALBUM_ID)
                && intent.hasParameter(ARG_ALBUM_POSITION)) {
            return new AlbumData(
                    intent.getLongParam(ARG_ALBUM_ID, -1),
                    intent.getStringParam(ARG_ALBUM_NAME),
                    intent.getIntParam(ARG_ALBUM_POSITION, -1)
            );
        }
        return null;
    }

    public static String ARG_ALBUM_ID = "album_id";
    public static String ARG_ALBUM_NAME = "album_name";
    public static String ARG_ALBUM_POSITION = "album_position";
}